package com.xuecheng.manage_cms.web.controller;

import com.xuecheng.api.cms.CmsPageControllerApi;
import com.xuecheng.framework.domain.cms.CmsPage;
import com.xuecheng.framework.domain.cms.request.QueryPageRequest;
import com.xuecheng.framework.domain.cms.response.CmsPageResult;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_cms.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cms/page")
public class CmsPageController implements CmsPageControllerApi {

    @Autowired
    PageService pageService;

    @Override
    @GetMapping("/list/{page}/{size}")
    public QueryResponseResult findList(@PathVariable("page") Integer page,@PathVariable("size") Integer size, QueryPageRequest queryPageRequest) {

        return pageService.findList(page,size,queryPageRequest);
    }

    @GetMapping("/findAliase")
    public QueryResponseResult findPageAliase( String siteId){

        return pageService.findPageAliase(siteId);
    }
    @PostMapping("/add")
    @Override
    public CmsPageResult add(@RequestBody CmsPage cmsPage) {
        return pageService.save(cmsPage);
    }

    @GetMapping("/get/{pageId}")
    public CmsPageResult findById(@PathVariable("pageId") String pageId){
        return pageService.findById(pageId);
    }
    @PutMapping("/edit/{pageId}")
    @Override
    public CmsPageResult update(@PathVariable("pageId") String pageId, @RequestBody CmsPage cmsPage) {
       return pageService.update(pageId,cmsPage);
    }
    @DeleteMapping("/del/{id}")
    @Override
    public ResponseResult delete(@PathVariable("id") String id) {
        return pageService.delById(id);
    }

    @Override
    public ResponseResult post(String pageId) {
        return null;
    }


}
